package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.AListOfUserExtraPermissionPackagesDTO;
import com.sc.nft.dto.AssignAPermissionPackageToTheUserDTO;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.feign.MerchantUserExtraPermissionClient;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.AListOfUserExtraPermissionPackagesVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户拥有的额外权限包列表(MerchantUserExtraPermission)表控制层
 *
 * @author wwc
 * @since 2023-03-28 11:05:29
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/merchantUserExtraPermission")
@Api(tags = "用户拥有的额外权限包列表")
public class MerchantUserExtraPermissionController {

    /**
     * 服务对象
     */
    private final MerchantUserExtraPermissionClient merchantUserExtraPermissionClient;

    @PostMapping(value = "assignAPermissionPackageToTheUser", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "给用户指定一个权限包", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result assignAPermissionPackageToTheUser(@RequestBody @Validated AssignAPermissionPackageToTheUserDTO assignAPermissionPackageToTheUserDTO) {
        return merchantUserExtraPermissionClient.assignAPermissionPackageToTheUser(assignAPermissionPackageToTheUserDTO);
    }

    @PostMapping(value = "getsAListOfUserExtraPermissionPackages", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取用户额外权限包的列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<AListOfUserExtraPermissionPackagesVO> getsAllPermissionPackages(@RequestBody @Validated AListOfUserExtraPermissionPackagesDTO aListOfUserExtraPermissionPackagesDTO) {
        return merchantUserExtraPermissionClient.getsAllPermissionPackages(aListOfUserExtraPermissionPackagesDTO);
    }

    @PostMapping(value = "removeTheUserPermissionPackage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除用户额外权限包", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result removeTheUserPermissionPackage(@RequestBody @Validated IdRequest idRequest) {
        return merchantUserExtraPermissionClient.removeTheUserPermissionPackage(idRequest);
    }

}
